package com.cvo.scrumtoolkit.client.controller;


/**
 * A navigator that serves as a nice data object to work with the WidgetFactory
 * Things that are wrong with the token will result in a default View type being set 
 * 
 * @author Ricardo Cappelle
 *
 */
public class Navigator {
	public final static String SLASH = "/";
	private static Navigator navigator;
	private View view;
	private String projectId;
	private String sprintId;
	
	/**
	 * A navigator may never be created by bad tokens so this is private
	 * @param view
	 * @param projectId
	 * @param sprintId
	 */
	private Navigator(View view, String projectId, String sprintId){
		this.view = view;
		this.projectId = projectId;
		this.sprintId = sprintId;
	}
	/**
	 * Creates a full Navigator from the tokens given in a safe way.
	 * Will call default panel if view String is non existing view
	 * Cannot be manipulated after creation for safety
	 * 
	 * @param token
	 * @return
	 */
	public static Navigator getNavigator(View view, String pid, String sprint) {
		View newview = view;
		String projectId = pid;
		String sprintId = sprint;
	
	
		navigator = new Navigator(newview, projectId, sprintId);

		return navigator;
	}
	public static Navigator getNavigator() throws Exception {
		if (navigator == null) {
			throw new Exception("Deze methode mag niet aangeroepen worden als er nog geen navigator bestaat.");
		}
		return navigator;
	}

	
	public View getView() {
		return view;
	}

	public String getProjectId() {
		return projectId;
	}

	public String getSprintId() {
		return sprintId;
	}

}
